package org.jeecgframework.tag.core.plugin.tag;

import java.io.StringWriter;
import java.io.Writer;
import java.util.Map;
import java.util.UUID;

import org.jeecgframework.tag.core.base.TagEnum;
import org.jeecgframework.tag.core.error.ParseRuntimeException;
import org.jeecgframework.tag.core.plugin.vo.ChooseTagModel;
import org.jeecgframework.tag.core.util.FreemarkUtil;

public class ChooseTag extends ChooseTagModel {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Override
    public String parseTag() {
        //随机一个函数名称,防止重名
        methodname = UUID.randomUUID().toString().replace("-", "").toUpperCase();
        Writer write = new StringWriter();
        try {
            FreemarkUtil.getTemplate(TagEnum.Choose).process(this, write);
        } catch (Exception e) {
            throw new ParseRuntimeException("Choose 文本解析异常", e.fillInStackTrace());
        }
        return write.toString();
    }

    public Map<String, String> getTagMap() {
        return FreemarkUtil.getTagNameMap();
    }

}
